# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Daniel Eklöf <daniel at ekloef dot se>

pkgbase=foot
pkgdesc='Fast, lightweight, and minimalistic Wayland terminal emulator'
pkgname=($pkgbase $pkgbase-terminfo)
pkgver=1.16.2
pkgrel=2
url="https://codeberg.org/dnkl/$pkgbase"
arch=(loong64 x86_64)
license=(MIT)
makedepends=(fcft
             fontconfig
             libutf8proc
             libxkbcommon
             llvm
             meson
             ncurses
             ninja
             pixman
             python
             scdoc
             sway
             tllist
             wayland
             wayland-protocols)
optdepends=('libutempter: utmp logging')
backup=(etc/xdg/foot/foot.ini)
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz")
sha256sums=('0e02af376e5f4a96eeb90470b7ad2e79a1d660db2a7d1aa772be43c7db00e475')

build() {
	cd "$pkgbase"
	./pgo/pgo.sh \
		full-headless-sway \
		. build \
		-Dterminfo=disabled \
		--prefix=/usr \
		--wrap-mode=nodownload
	sed 's/@default_terminfo@/foot-extra/g' foot.info |
		tic -x -o build -e foot-extra,foot-extra-direct -
}

check() {
	cd "$pkgbase"
	ninja -C build test
}

package_foot() {
	optdepends=('foot-terminfo: exta non-standard features over terminfo included in ncurses'
	            'libnotify: desktop notifications'
	            'xdg-utils: URI launching')
	depends=(fcft
	         fontconfig
	         libfcft.so
	         libutf8proc
	         libxkbcommon
	         ncurses
	         pixman
	         wayland)
	cd "$pkgbase"
	DESTDIR="$pkgdir" ninja -C build install
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}

package_foot-terminfo() {
	pkgdesc="Extra non-standard terminfo files for $pkgbase, a Wayland terminal emulator"
	depends=(ncurses)
	cd "$pkgbase"
	install -Dm0644 -t "$pkgdir/usr/share/terminfo/f/" build/f/foot-extra*
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
